#!/usr/bin/env python
# -*- coding: utf-8-*-

from binance.client import Client
from enum import Enum
import json

class OrderType(Enum):
    LIMIT = "LIMIT"
    MARKET = "MARKET"
    STOP = "STOP"

class Futures(object):

    def __init__(self, api_key=None, api_secret=None):
    self.api_key = api_key
    self.api_secret = api_secret

    """
        获取合约账户信息   eg:BUSD  USDT  ETH  BTC
        获取合约资产 -- 获取合约账户余额
                account = client.futures_account_balance();
        调用mybinace
                balance = mybinance.futures.get_futures_account_balance(client,'BUSD')
        print(balance)
    """
    def get_futures_account_balance(self,asset_str):
        client = Client(self.api_key, self.api_secret)
        balance = 0;
        futures_account_balance = json.dumps(client.futures_account_balance());
        json_list = json.loads(futures_account_balance);
            for key in json_list:
                if(asset_str == key['asset']):
        balance = key['balance']
        return balance

    """
        调整U本位合约杠杆倍数
        交易对 杠杆倍数
    """
    def change_futures_leverage(self,symbol,leverage):
        client = Client(self.api_key, self.api_secret)
        return client.futures_change_leverage(symbol=symbol,leverage=leverage)

    """
        获取Kline
        交易对 时间周期
    """
    def futures_klines(self,symbol,interval):
    client = Client(self.api_key, self.api_secret)
        return client.futures_klines(symbol=symbol,interval=interval)


futures = Futures(object)